package com.autonavi.yunda.yunji.core.model.dto;

import com.autonavi.yunda.yunji.core.enums.FunctionStatus;
import com.autonavi.yunda.yunji.core.enums.FunctionType;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.sql.Timestamp;

import static com.autonavi.yunda.yunji.core.config.EngineConstant.FUNCTION_VERSION_SEPARATOR;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("yunji_function_config")
public class FunctionConfigDTO {
    @TableId(type = IdType.AUTO)
    private Long id;
    private String name;
    private String params;
    private String description;
    private FunctionType type;
    private FunctionStatus status;
    private String version;
    @TableField("debug_result")
    private String debugResult;
    @TableField("function_script")
    private String functionScript;
    @TableField("create_user")
    private String createUser;
    @TableField("update_user")
    private String updateUser;
    @TableField("create_time")
    private Timestamp createTime;
    @TableField("update_time")
    private Timestamp updateTime;

    public String getFunctionKey() {
        return this.name + FUNCTION_VERSION_SEPARATOR + this.version;
    }
}
